<?php

namespace App\Validation;


use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Regex;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\StringLength;

class LoginValidation extends BaseValidation
{
    public function initialize()
    {
        $this->add(
            "mobile",
            new PresenceOf(
                [
                    "message" => "The mobile is required",
                ]
            )
        );
		
		$this->add(
			"mobile",
			new Regex(
				[
					"message"    => "The mobile format is not correct",
					"pattern"    => "/^1[34578]\d{9}$/",
					"allowEmpty" => true,
				]
			)
		);
		
        $this->add(
            "code",
            new PresenceOf(
                [
                    "message" => "The code is required",
                ]
            )
        );
		
		$this->add(
			"code",
			new Numericality(
				  [
					  "message" => ":field is not numeric",
					  "allowEmpty" => true,
				  ]
			)
		);
		
		$this->add(
			"code",
			new StringLength(
				  [
					  "messageMinimum" => "The code Go beyond",
					  "min" => 4,
				  ]
			)
		);		
		
		
    }
}